package org.southyin.controller.cms_customer;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.southyin.model.CmsCustomer;
import org.southyin.service.CmsCustomerService;
import org.southyin.service.impl.CmsCustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user/personal")
public class CmsPersonalServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("authorId");
        CmsCustomerService service = new CmsCustomerServiceImpl();
        CmsCustomer user = service.getPersonInfos(Long.valueOf(id));
        resp.getWriter().println(new ObjectMapper().writeValueAsString(user));
    }
}
